<!--
 * @Descripttion: 分享设置
 * @Author: xiao li
 * @Date: 2020-07-06 12:17:07
 * @LastEditors: xiao li
 * @LastEditTime: 2021-06-18 12:27:07
-->
<template>
  <div class="lb-sys-share">
    <top-nav></top-nav>
    <div class="page-main">
      <el-form
        @submit.native.prevent
        :model="subForm"
        ref="subForm"
        label-width="140px"
        class="sub-form"
      >
        <el-form-item label="分享好友多选">
          <el-radio-group v-model="subForm.share_more">
            <el-radio :label="0">{{$t('action.OFF')}}</el-radio>
            <el-radio :label="1">{{$t('action.ON')}}</el-radio>
          </el-radio-group>
          <lb-tool-tips>
            <div class="pb-md">注：开启后分享给好友小程序页面可以多选，但不能使用群监控功能</div>
            群监控功能：雷达记录新用户来自于哪个微信群聊

          </lb-tool-tips>
          </el-form-item>
        <el-form-item>
          <lb-button type="primary" @click="submitFormInfo(2)">{{$t('action.submit')}}</lb-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      subForm: {
        share_more: 0
      },
      configInfo: {}
    }
  },
  created () {
    this.submitFormInfo(1)
  },
  methods: {
    async submitFormInfo (type) {
      let {configInfo, subForm} = this
      if (type === 2) {
        for (let key in subForm) {
          configInfo.new_setting[key] = subForm[key]
        }
      }
      let param = type === 1 ? '' : configInfo
      let {code, data} = await this.$api.getCardDefaultSetting(param)
      if (code !== 200) return
      if (type === 1) {
        this.configInfo = data
        for (let key in this.subForm) {
          this.subForm[key] = data.new_setting[key]
        }
      } else {
        this.$message.success(this.$t('tips.successSub'))
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.lb-sys-share {
  width: 100%;
  .sub-form {
    .el-input,
    .el-select {
      width: 300px;
    }
  }
}
</style>
